package dao

import (
	"database/sql"
	"time"

	"github.com/go-sql-driver/mysql"
)

func connect() (*sql.DB, error) {
	cfg := mysql.Config{
		User:                 "",
		Passwd:               "",
		Net:                  "tcp",
		Addr:                 "",
		AllowNativePasswords: true,
		DBName:               "mix",
	}
	db, err := sql.Open("mysql", cfg.FormatDSN())
	if err != nil {
		// log.Fatal(err)
		return nil, err
	}

	db.SetConnMaxLifetime(2 * time.Minute)
	return db, nil
}
